#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

//void *buzzer(void *date)
int main(int argc, const char *argv[])
{
	int fd1 = 0;
	int flag;

	while(1){
//		pthread_mutex_lock(&mutex5);

		fd1 = open("/dev/buzzer", O_RDWR);
		if(fd1 < 0){
			perror("open_buzzer");
			exit(1);
		}

		flag = 1;
		write(fd1, &flag, 4);
		sleep(1);
		flag = 0;
		write(fd1, &flag, 4);
		return 0;

#if 0
		//蜂鸣器协议
		//温度：100
		//湿度：010
		//光照：110
		if(to_float(recv.temp) < shm_buf->rt_status.storage_no[1].temperatureMIN ||
			to_float(recv.temp) > shm_buf->rt_status.storage_no[1].temperatureMAX){ 
			//打开峰鸣器
			flag = 1;
			write(fd1, &flag, 4);
			sleep(0.5);

		}else if(to_float(recv.hum) < shm_buf->rt_status.storage_no[1].humidityMIN ||
			to_float(recv.hum) > shm_buf->rt_status.storage_no[1].humidityMAX){
			//打开峰鸣器 

		}else if((float)recv.ill < shm_buf->rt_status.storage_no[1].illuminationMIN ||
			(float)recv.ill > shm_buf->rt_status.storage_no[1].illuminationMAX){
			//打开峰鸣器 
		
		}
#endif
	}
}
